package com.job.common.converter;

import com.job.pojo.Corporation;
import com.job.pojo.vo.CorporationVO;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class CorporationFieldConverter {

    /**
     * 公司规模：
     * 0 0-22
     * 1 22-99
     * 2 100-499
     * 3 500-999
     * 4 1000-9999
     * 5 1000以上
     */
    private static final Map<Integer,String> scaleMap = new HashMap<Integer,String>(){{
        put(0,"不限");
        put(1,"0-20人");
        put(2,"22-99人");
        put(3,"100-499人");
        put(4,"500-999人");
        put(5,"1000-9999人");
        put(6,"10000人以上");
    }};

    /**
     * 融资阶段：
     * 0：不限
     * 1：未融资
     * 2：天使轮
     * 3：A轮
     * 4：B轮
     * 5：C轮
     * 6：D轮以上
     * 7：已上市
     * 8：不需要融资
     * @return
     */
    private static final Map<Integer,String> financingMap = new HashMap<Integer,String>(){{
        put(0,"不限");
        put(1,"未融资");
        put(2,"天使轮");
        put(3,"A轮");
        put(4,"B轮");
        put(5,"C轮");
        put(6,"D轮以上");
        put(7,"已上市");
        put(8,"不需要融资");
    }};

    public CorporationVO corporationPoToVoConverter(Corporation corporation){
        CorporationVO corporationVO = new CorporationVO();
        corporationVO.setCorporationId(corporation.getCorporationId());
        corporationVO.setCorporation(corporation.getCorporation());
        corporationVO.setLogo(corporation.getLogo());
        corporationVO.setWelfare(corporation.getWelfare());
        corporationVO.setIsUp(corporation.getIsUp() == 0 ? "未上市" : "已上市");
        corporationVO.setScale(scaleMap.get(corporation.getScale()));
        corporationVO.setFinancing(financingMap.get(corporation.getFinancing()));
        return corporationVO;
    }
}
